package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	for _, url := range os.Args[1:] {
		if strings.HasPrefix(url, "http") || strings.HasPrefix(url, "https") {
			fetch(url)
		} else {
			url = "http://" + url
			fetch(url)
		}
	}
}

func fetch(url string) {
	resp, err := http.Get(url)
	if err != nil {
		fmt.Fprintf(os.Stderr, "fetch: %v", err)
		os.Exit(1)
	}
	data, err := io.Copy(os.Stdout, resp.Body)
	if err != nil {
		fmt.Fprintf(os.Stderr, "reading: %v", err)
		os.Exit(1)
	}
	fmt.Printf("%v\n%s\nstatusCode is %d\n", data, strings.Repeat("-", 100), resp.StatusCode)
}
